#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
// 判断client end socket请求是否继续存在
int isSocketConnected(int sockFd)
{
  if(sockFd<0){
    return -1;
  }
  // int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen);
  struct tcp_info info;
  int len = sizeof(info);
  getsockopt(sockFd,IPPROTO_TCP,TCP_INFO,&info,(socklen_t * )&len);
  
  if(info.tcpi_state == TCP_ESTABLISHED){
    return 0;
  }else{
    return -1;
  }
}
